package string;

public class ComplexNumberMultiplication537 {
    public String complexNumberMultiply(String num1, String num2) {
        String[] num1s = num1.split("\\+");
        String[] num2s = num2.split("\\+");
        int a1 = Integer.valueOf(num1s[0]);
        int b1 = Integer.valueOf(num2s[0]);
        String num1s1 = num1s[1].substring(0, num1s[1].length() - 1);
        int a2 = num1s1.charAt(0) == '-' ? -Integer.valueOf(num1s1.substring(1)) : Integer.valueOf(num1s1);
        String num2s1 = num2s[1].substring(0, num2s[1].length() - 1);
        int b2 = num2s1.charAt(0) == '-' ? -Integer.valueOf(num2s1.substring(1)) : Integer.valueOf(num2s1);
        int zhengshu = a1 * b1 -
                a2 * b2;
        int xushu = a1 * b2 + a2 * b1;
        return zhengshu + "+" + xushu + "i";
    }
}
